matrix gWVP;
matrix gWorld;
matrix gWorldInverTran;
matrix gViewProj;
float3 gLightDir;
texture gTex0;

sampler tex0Sampler = sampler_state
{
	Texture = <gTex0>;
	MinFilter = LINEAR;
	MipFilter = LINEAR;
	MagFilter = LINEAR;
};

struct Output
{
	float4 posH		:	POSITION0;
	float2 tex		:	TEXCOORD0;
	float3 normal	:	TEXCOORD1;
};

Output TreeVS(float3 posL:POSITION0,float3 normalL:NORMAL0,float2 tex:TEXCOORD0)
{
	Output outVert = (Output)0;
	outVert.posH = mul( float4( posL, 1.0f ), gWVP );
	outVert.normal = mul( float4( normalL, 0.0f ), gWorldInverTran ).xyz;
	outVert.tex = tex;
	return outVert;
}
float4 TreePS(float2 tex:TEXCOORD0, float3 normal:TEXCOORD1 ):COLOR0
{
	float4 finalColor = tex2D(tex0Sampler,tex);
	normalize( normal );
	normalize( gLightDir ); 
	float diffuseCoef = saturate ( dot( normal, -gLightDir ) );
	float ambientCoef = 0.3;
	return ( diffuseCoef + ambientCoef ) * finalColor;
}

technique TreeTech
{
	pass P0
	{
		vertexShader = compile vs_2_0 TreeVS();
		pixelShader = compile ps_2_0 TreePS();
		//FillMode = wireframe;
		//cullmode = none;
	}
}

